if __name__=="__main__":
    a,b=map(lambda x:int(x),input().split())
    if a<b:
        c=a
        a=b
        b=c
    while b!=0:
        rem=a%b
        a=b
        b=rem
    print(a)


